<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>新经资讯后台管理</title>
    <link rel="stylesheet" type="text/css" href="../../static/admin/css/reset.css">
    <link rel="stylesheet" type="text/css" href="../../static/admin/css/main.css">
    <link rel="stylesheet" href="../../static/admin/css/jquery.pagination.css">
    <script type="text/javascript" src="../../static/admin/js/jquery-1.12.4.min.js"></script>
    <script type="text/javascript" src="../../static/admin/js/jquery.pagination.min.js"></script>
</head>
<body>
<div class="breadcrub">
    当前位置：新闻管理>新闻审核
    <form class="news_filter_form">
        <input type="text" name="key" placeholder="请输入关键字" class="input_txt">
        <input type="submit" value="搜 索" class="input_sub">
    </form>
</div>
<div class="pannel">
    <table class="common_table">
        <tr>
            <th width="3%">id</th>
            <th width="70%">标题</th>
            <th width="15%">发布时间</th>
            <th width="5%">状态</th>
            <th width="8%">管理操作</th>
        </tr>
        {# 遍历显示新闻信息 #}
        {% for news in news_li %}
        <tr>
            {# 新闻id #}
            <td>{{ news.id }}</td>
            {# 新闻标题 #}
            <td class="tleft">{{ news.title }}</td>
            {# 新闻发布时间 #}
            <td>{{ news.create_time }}</td>
            {# 新闻状态 #}
            <td>{{ news.status|news_status }}</td>
            <td>
                <a href="{{ url_for('admin.news_review_detail', news_id=news.id) }}" class="review">审核</a>
            </td>
        </tr>
        {% endfor %}
    </table>
</div>

<div class="box">
    <div id="pagination" class="page"></div>
</div>

<script>
    //解析url中的查询字符串
    function decodeQuery() {
        var search = decodeURI(document.location.search);
        return search.replace(/(^\?)/, '').split('&').reduce(function (result, item) {
            values = item.split('=');
            result[values[0]] = values[1];
            return result;

        }, {});

    }

    $(function () {
        $("#pagination").pagination({
            currentPage: {{current_page }},
            totalPage: {{ total_page }},
            callback: function (current) {
                //alert('ok!');
                //location.href = '/admin/news/review?p=' + current;
                var params = decodeQuery();
                var key = params['key'];

                if (!key) {
                    location.href = '/admin/news/review?p=' + current;
                }
                else {
                    location.href = '/admin/news/review?p=' + current + '&key=' + key;
                }

            }
        });
    });
</script>
</body>
</html>